<template>
    
    <!-- 组件的模板 -->
  
    <div class="page user-select multi-select"  v-show="searchInput.length">
        <ul class="list com-border-top com-border-bottom">
            <li class="weui-cells_checkbox"  v-for="group in searchResultList">
               <label class="touch" for="{{group.id}}"> <!--:class="{'setHui':!group.action}"-->
                <div class="info com-border-bottom"  @click="selectGroup(group)">
                    <p class="title">{{group.name}}</p>
                </div>
              </label>
            </li>
        </ul>
       
    </div>
</div>

</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */
    import cache from 'gapi/cache.js'
    import commonPage from 'clientApi/commonPage.js'
    import searchPage from 'clientApi/searchPage.js'

    
    /**
     *  组件实例对象
     */
    export default {
        components: {
            
        },
        data: function(){
            return{
               searchInput:'',
               selectGroupList:[],
               allGroupList:[]
            }
        },
        computed:{
            searchResultList(){
                var searchResultList = []
                this.allGroupList.forEach((item)=>{
                    if(item.name.indexOf(this.searchInput)>-1){
                        searchResultList.push(item)
                    }
                })
                
                return searchResultList
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){    
                cache.getMemoryCache('allGroupList', (data) => {
                    console.log(data)
                    if(data){
                        this.allGroupList = data
                    }
                })
                window.getSearchResult=(data)=>{
                    this.searchInput = data
                }
            },
            selectGroup(group){
                cache.getMemoryCache('selectDepartmentWebViewID',(data)=>{
                    if(data){
                        commonPage.goBack(1,{'key':'selectGroup','value':group},data.webViewID)
                    }
                })
            }
        },
        created(){
            this.init();
            
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/user-list.css"></style>

<style>
   
    .weui-cells_checkbox .setHui{
        color:#bbbbbb
    }
</style>
